package com.bean;

import java.util.ArrayList;
import java.util.Collection;

public class AbstractBean {
	
	private Collection<Exception> errors;
	protected int pageNumber;
	private int lastPage;
	
	public AbstractBean(){
		errors=new ArrayList<Exception>();
	}
	
	protected void addError(Exception e){
		errors.add(e);
	}
	
	public Collection getErrors(){
		return errors;
	}
	
	public boolean hasErrors(){
		return !errors.isEmpty();
	}
	
	public void next(){
		if(pageNumber<lastPage){
			pageNumber++;
		}else{
			pageNumber=lastPage;
		}
	}
	
	public void previous(){
		if(pageNumber>1){
			pageNumber--;
		}else{
			pageNumber=1;
		}
	}
	public void last(){
		pageNumber=lastPage;
	}
	
	public void first(){
		pageNumber=1;
	}
	
	public Collection getActualPage(){
		return null;
	}
	
	public void setLastPage(int p){
		lastPage=p;
	}
	
}
